<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>发布车辆</title>
	<link rel="stylesheet" href="assets/layui/css/layui.css">
	<link rel="stylesheet" href="assets/css/all.css">
	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
	  	<script src="assets/js/html5shiv.js"></script>
	  	<script src="assets/js/respond.min.js"></script>
	<![endif]-->
	</head>

	<body>
		<div class="layui-fluid">
			<div class="layui-form">
				<div class="layui-form-item">   
					<div class="layui-input-inline">
						<input style="width:500px;" id="key1" type="text" name="title" lay-verify="" placeholder="填写符合条件的搜索内容，例：车辆状态、车牌号、车牌、车型、报案号" autocomplete="off" class="layui-input"> 
					</div>
					<button style="margin-left:302px" class="layui-btn layui-btn-primary searchBtn" data-type="reload"><i class="layui-icon">&#xe615;</i>查询</button>
					<button class="layui-btn delBtn layui-btn-danger"><i class="layui-icon">&#xe640;</i>删除</button>
			        <button class="layui-btn submit-btn" data-type="reload" lay-filter="submit-btn">导出</button>
			        <button class="layui-btn freshBtn layui-btn-green"><i class="layui-icon">&#x1002;</i>刷新</button>
			        <a href="" target="_blank" id="export" style="display:none;"></a>
				</div>
			</div>
			<div class="addNew"><button class="layui-btn layui-btn-danger"><i class="layui-icon">&#xe608;</i>发布车辆</button></div>
			<table class="layui-hide" id="car-type" lay-filter="carTypeTable"></table>
			<script type="text/html" id="checkInfor">
				<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit">编辑</a>
			</script>
		</div>
		<script src="assets/layui/layui.js"></script>
		<script src="assets/js/all.js"></script>
		<script type="text/javascript">
			layui.use(['table','layer','laypage','form'],function(){
				var table = layui.table,
					layer = layui.layer,
					laypage = layui.laypage,
					form = layui.form,
					$ = layui.$
					
					//车辆管理状态页面js					
					//方法级渲染
					var tableIn = table.render({
						elem: '#car-type',
						url: 'assets/data/demo.json',
						cols: [
							[{
								type:'checkbox'
							},{
								field: 'id',
								title: '车辆编号',
								width: 100,
								//sort: true,
								//fixed: true
							}, {
								field: 'cartype',
								title: '车型',
								width: 180
							},{
								field: 'sign',
								title: '车牌号',
								width: 280
							},{
								field: 'company',
								title: '所属保险公司',
								width: 280
							},{
								field: 'wealth',
								title: '车辆类型',
								width: 100
							},{
								//fixed: 'right',
								width: 100,
								align: 'center',
								toolbar: '#checkInfor'
							}]
						],
						page:true,
						limit: 10,
						limits:[10]
//						,done:function(res,curr,count){//res即为你接口返回的信息,curr 是当前页，count总页数
//							if(res.code == 0){
//								layer.msg(res.msg);
//							}
//							if(res.code == 1){
//								
//							}
//						}
					});

					$('.searchBtn').on('click', function() {
						var key1 = $('#key1').val();	
							//执行重载
							tableIn.reload({
//								if(key1==''&key2==''&key3=''){
//									layer.msg("请输入搜索内容");
//									return;
//								}
								page: {
									curr: 1 //重新从第 1 页开始
								},
								where: {
									key1: key1,
								}
							});
					});
				
					//监听工具条
					table.on('tool(carTypeTable)', function(obj) {
						var data = obj.data;
						if(obj.event === 'edit') {
							var index = layer.open({
								type:2,
								title:'编辑车辆信息',
								content:'editCarInfor.html'
							});
							layer.full(index);
						} 

					});
					
					//添加新的车辆信息
					$(".addNew button").click(function(){
						var index = layer.open({
							type:2,
							title:'新增车辆信息',
							content:'addCarInfor.html'
						});
						layer.full(index);
					});
					
					//批量删除
					$(".delBtn").click(function(){
						var checkStatus = table.checkStatus('car-type')
						,data = checkStatus.data;
						var str="";
						if(data.length>0){
							for(var i=0;i<data.length;i++){
								str+=data[i].id+",";
							}
							layer.confirm('是否删除这'+data.length+'条数据？',{icon:3,title:'提示'},function(index){
								window.location.href="deleteUserinfos?str="+str+"";
								layer.close(index);
							})
						}else{
							layer.alert("请选择要删除的数据")
						}
					});
	
			})
		</script>

	</body>

</html>